require 'will_paginate'
class DisciplinatypesController < ApplicationController
  
  

  # GET /disciplinatypes
  # GET /disciplinatypes.xml
  def index
    #@disciplinatypes = Disciplinatype.paginate :page => params[:page], :order => 'nome DESC', :per_page => 8
    @nome = params[:nome]
    @disciplinatypes =  Disciplinatype.search @nome, params[:page]

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @disciplinatypes }
    end
  end

  # GET /disciplinatypes/1
  # GET /disciplinatypes/1.xml
  def show
    @disciplinatype = Disciplinatype.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @disciplinatype }
    end
  end

  # GET /disciplinatypes/new
  # GET /disciplinatypes/new.xml
  def new
    @disciplinatype = Disciplinatype.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @disciplinatype }
    end
  end

  # GET /disciplinatypes/1/edit
  def edit
    @disciplinatype = Disciplinatype.find(params[:id])
  end

  # POST /disciplinatypes
  # POST /disciplinatypes.xml
  def create
    @disciplinatype = Disciplinatype.new(params[:disciplinatype])

    @disciplinatype = modifica @disciplinatype,params[:disciplinatype]

    respond_to do |format|
      if @disciplinatype.save
        flash[:notice] = 'Disciplinatype was successfully created.'
        format.html { redirect_to(@disciplinatype) }
        format.xml  { render :xml => @disciplinatype, :status => :created, :location => @disciplinatype }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @disciplinatype.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /disciplinatypes/1
  # PUT /disciplinatypes/1.xml
  def update
    @disciplinatype = Disciplinatype.find(params[:id])

    respond_to do |format|
      if @disciplinatype.update_attributes(params[:disciplinatype])
        flash[:notice] = 'Disciplinatype was successfully updated.'
        format.html { redirect_to(@disciplinatype) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @disciplinatype.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /disciplinatypes/1
  # DELETE /disciplinatypes/1.xml
  def destroy
    @disciplinatype = Disciplinatype.find(params[:id])
    @disciplinatype.destroy

    respond_to do |format|
      format.html { redirect_to(disciplinatypes_url) }
      format.xml  { head :ok }
    end
  end
end
